package cn.xuchunh.sword;

/**
 * Created by XuChunH on 2016/9/18.
 */
public class LeftRotateString {

    public String solution(String str, int n) {
        if(str == null){
            return null;
        }
        if(str.isEmpty()){
            return "";
        }
        n = n % str.length();
        char[] temp = new char[str.length()];
        for (int i = 0; i < temp.length - n; i++) {
            temp[i] = str.charAt(n + i);
        }
        for (int i = temp.length - n; i < temp.length; i++) {
            temp[i] = str.charAt(i - (temp.length - n));
        }
        return new String(temp);
    }

}
